package com.zhuguowei.mytoast;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.Toast;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

public class MainActivity extends AppCompatActivity {


    @BindView(R.id.btn_txt_bg_color)
    Button mBtnTxtBgColor;
    @BindView(R.id.btn_txt_bg)
    Button mBtnTxtBg;
    @BindView(R.id.btn_image)
    Button mBtnImage;
    @BindView(R.id.btn_view)
    Button mBtnView;
    private ToastUtils mToastUtils;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        ButterKnife.bind(this);

    }

    @OnClick({R.id.btn_txt_bg_color, R.id.btn_txt_bg, R.id.btn_image, R.id.btn_view})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.btn_txt_bg_color:
                ToastUtil toastUtil = new ToastUtil();
                toastUtil.Short(MainActivity.this, "改变字体颜色和背景颜色").setToastColor(getResources().getColor(R.color.public_blue)
                        , getResources().getColor(R.color.public_yellow)).show();
//                ToastUtil toastUtil = new ToastUtil();
//                toastUtil.Short(MainActivity.this, "自定义message字体、背景色").setToastColor(Color.WHITE, getResources().getColor(R.color.colorAccent)).show();

                break;
            case R.id.btn_txt_bg:
                ToastUtils toastUtils1 = new ToastUtils();
                toastUtils1.Short(MainActivity.this, "改变字体颜色和背景").setToastBackground(getResources().getColor(R.color.public_blue)
                        , R.drawable.toast_radius).show();
                break;
            case R.id.btn_image:
                mToastUtils = new ToastUtils();
                ImageView imageView = new ImageView(getApplicationContext());
                imageView.setImageResource(R.mipmap.ic_launcher_round);
                mToastUtils.Short(MainActivity.this, "改变字体颜色和背景加上图片").setToastBackground(getResources().getColor(R.color.public_blue)
                        , R.drawable.toast_radius).addView(imageView, 0).show();
                break;
            case R.id.btn_view:
                View myView = LayoutInflater.from(MainActivity.this).inflate(R.layout.image,null);
                mToastUtils = new ToastUtils(MainActivity.this,myView, Toast.LENGTH_SHORT).show();
                break;
        }
    }
}
